home *** CD-ROM | disk | FTP | other *** search
/ GameStar 2006 February / Gamestar_81_2006-02_dvd.iso / Red Shark / Missions / Mission_6 / Mission.script < prev    next >
Text File  |  2001-12-19  |  6KB  |  205 lines

  1. //-------------------------------------------------------------------
  2. //
  3. //  This code is copyright 2001 by G5 Software.
  4. //  Any unauthorized usage, either in part or in whole of this code
  5. //  is strictly prohibited. Violators WILL be prosecuted to the
  6. //  maximum extent allowed by law.
  7. //
  8. //-------------------------------------------------------------------
  9.  
  10. class CPreventVillageDestructionMission extends
  11.   CBaseMission, CPreventVillageDestructionMissionObjectList, CPreventVillageDestructionMission_Strings, CNavPointUser
  12. {
  13.   int GetAutoGeneratedUnitsQty()
  14.   {
  15.     return 6;
  16.   }
  17.  
  18.   void CPreventVillageDestructionMission()
  19.   {
  20.     BaseMission_InitMission();
  21.  
  22.     BaseMission_UpdateLoadProgress();
  23.     CreateComponent("DebugCamera", "GameObject", "CDebugCamera");
  24.     SetComponentPosition("DebugCamera",
  25.       matrix(
  26.         1.0, 0.0, 0.0, 8000.0,
  27.         0.0, 1.0, 0.0, 8000.0,
  28.         0.0, 0.0, 1.0,  600.0,
  29.         0.0, 0.0, 0.0,    1.0
  30.       ));
  31.  
  32.     // CreateComponent(IDToRegister, ComponentID, ScriptName | FileName | "")
  33.     BaseMission_UpdateLoadProgress();
  34.     CreateComponent("Atmosphere", "Atmosphere", "CPreventVillageDestructionMission_Atmosphere");
  35.  
  36.     BaseMission_UpdateLoadProgress();
  37.     CreateComponent("Sky", "SkyObject", "CPreventVillageDestructionMission_Sky");
  38.  
  39.     BaseMission_UpdateLoadProgress();
  40.     CreateComponent("Terrain", "ProgressiveTerrainObject", "CPreventVillageDestructionMission_Terrain");
  41.  
  42.     BaseMission_UpdateLoadProgress();
  43.     CreateComponent("Forest", "Forest", "CPreventVillageDestructionMission_Forest");
  44.  
  45.     BaseMission_UpdateLoadProgress();
  46.     CreateComponent("AIController", "AIController", "CBaseAIController");
  47.  
  48.     BaseMission_CreateObjects();
  49.  
  50.     //
  51.     //  Mission specific
  52.     //
  53.  
  54.     // count how many 1st and 2nd objectives' objects are in the mission
  55.     array m_Objects = GetObjectsIDs();
  56.  
  57.     m_EnemiesCount    = 0;
  58.     m_StructuresCount = 0;
  59.  
  60.     for (int i = 0; i < m_Objects.size(); i = i + 1)
  61.     {
  62.       if (Core_IsStringStartsWith(m_Objects[i], "Nazi"))
  63.         m_EnemiesCount = m_EnemiesCount + 1;
  64.  
  65.       if (Core_IsStringStartsWith(m_Objects[i], "HQHouse"))
  66.         m_StructuresCount = m_StructuresCount + 1;
  67.     }
  68.  
  69.     m_StructuresDestroyed = 0;
  70.     m_EnemiesDestroyed    = 0;
  71.   }
  72.  
  73.   int  m_StructuresCount;
  74.   int  m_StructuresDestroyed;
  75.  
  76.   int  m_EnemiesCount;
  77.   int  m_EnemiesDestroyed;
  78.  
  79.   array m_MissionObjectivesStatuses =
  80.           array(
  81.             str_ObjectiveInProgress,
  82.             str_ObjectiveInProgress
  83.           );
  84.  
  85.   array m_BonusMissionObjectivesStatuses =
  86.           array();
  87.  
  88.   //
  89.   //  'virtual' methods
  90.   //
  91.  
  92.   //
  93.   //  Mission statistics
  94.  
  95.   string GetMissionStatistics()
  96.   {
  97.     int structures_left = (m_StructuresCount - m_StructuresDestroyed) * 100 / m_StructuresCount;
  98.     int enemies_killed  = m_EnemiesDestroyed * 100 / m_EnemiesCount;
  99.  
  100.     string message =
  101.       str_StatisticsTitle_1 + structures_left + "%" + EOLN +
  102.       str_StatisticsTitle_2 + enemies_killed  + "%";
  103.  
  104.     return message;
  105.   }
  106.  
  107.   //
  108.   //  Mission navpoints
  109.  
  110.   array GetNavPoints()
  111.   {
  112.     array navpoints =
  113.       array(
  114.         GetNavPoint("NavPoint_Vasyki"),
  115.         GetNavPoint("NavPoint_Marshevka"),
  116.         GetNavPoint("NavPoint_Gotovtsevo"),
  117.         GetNavPoint("NavPoint_Barinovo"),
  118.         GetNavPoint("NavPoint_Upyryovka"),
  119.         GetNavPoint("NavPoint_Korzhebino"),
  120.         GetNavPoint("NavPoint_Ovechkino"),
  121.         GetNavPoint("NavPoint_Gerasimovo"),
  122.         GetNavPoint("NavPoint_Ozerino")
  123. //
  124. //        vector(7967.0, 8364.0, 600.0),
  125. //        vector(2017.0, 3896.0, 0.0),
  126. //        vector(3880.0, 12547.0, 600.0),
  127. //        vector(11864.0, 13886.0, 600.0),
  128. //        vector(11133.0, 11016.0, 600.0),
  129. //        vector(14715.0, 10547.0, 600.0),
  130. //        vector(13622.0, 4694.0, 600.0),
  131. //        vector(11463.0, 3015.0, 600.0),
  132. //        vector(7205.0, 3563.0, 600.0)
  133.       );
  134.     return navpoints;
  135.   }
  136.  
  137.   //
  138.   //  Mission map skin file
  139.  
  140.   string GetMapSkinFileName()
  141.   {
  142.     return "Missions/Mission_6/Map.skin";
  143.   }
  144.  
  145.   //
  146.   //  Mission specific event handlers
  147.   //
  148.  
  149.   //
  150.   //  Object destroyed event handler
  151.   //
  152.  
  153.   void OnGameObjectDestroyed(string _id)
  154.   {
  155.     BaseMission_OnGameObjectDestroyed(_id);
  156.  
  157.     if (Core_IsStringStartsWith(_id, "HQHouse"))
  158.     {
  159.       m_StructuresDestroyed = m_StructuresDestroyed + 1;
  160.  
  161.       int percent_left = (m_StructuresCount - m_StructuresDestroyed) * 100 / m_StructuresCount;
  162.  
  163.       string message = str_WarningMessage + percent_left + "%";
  164.  
  165.       Core_BroadcastEvent(
  166.         "OnDisplayMessage",
  167.         message,
  168.         m_BadNewsColor
  169.       );
  170.       Core_SendEventTo(
  171.         "Helicopter",
  172.         "ShowEventObject",
  173.         _id,                       //     - id of object to show
  174.         170.0                      //     - distance from camera to object
  175.         );
  176.     }
  177.  
  178.     // check for failed 1st objective
  179.     if (m_StructuresDestroyed > m_StructuresCount / 2)
  180.     {
  181.       BaseMission_DelayedQuit();
  182.     }
  183.  
  184.     if (Core_IsStringStartsWith(_id, "Nazi"))
  185.     {
  186.       m_EnemiesDestroyed = m_EnemiesDestroyed + 1;
  187.     }
  188.  
  189.     // check for completed 2nd objective
  190.     if (m_EnemiesDestroyed == m_EnemiesCount)
  191.     {
  192.       BaseMission_CompleteObjective(0); // 1st is completed if we haven't exited yet
  193.       BaseMission_CompleteObjective(1);
  194.     }
  195.   }
  196.  
  197.   void OnMissionLoaded()
  198.   {
  199.     Core_SendEventTo("Helicopter", "OnInitiallyEnableTargetScreen", false);
  200.  
  201.     // Start mission music playing
  202.     Core_SendEventTo(SOID_MusicController, "PlayMissionMusic", 6);
  203.   }
  204. }
  205.